package com.yh.correct.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.annotation.RequestScope;
import org.springframework.web.servlet.ModelAndView;

import com.yh.correct.model.CorrectedPerson;
import com.yh.correct.model.Empolyment;
import com.yh.correct.model.Job;
import com.yh.correct.model.JudicialDeptment;
import com.yh.correct.model.Page;
import com.yh.correct.model.ResultData;
import com.yh.correct.service.impl.EmpolymentServiceImpl;

@RestController
@RequestMapping("/empolyment")
public class EmpolymentController {
	private static Logger logger = LogManager.getLogger(EmpolymentController.class);
	@Autowired
	private EmpolymentServiceImpl el;

	@RequestMapping("/gete")
	public ModelAndView get(){
		return new ModelAndView("education/empolyment");
		
	}
	@RequestMapping("/get")
	public ResultData getAll(String jobname,String cname,String jname, int pageSize, int pageNum){
		ResultData rd = new ResultData(); 
		Job job = new Job();
		if (jobname == null) {
			jobname = "";
		}
		 job.setName(jobname);
		 CorrectedPerson c = new CorrectedPerson();
		 if (cname == null) {
				cname = "";
			}
		 c.setName(cname);
		 JudicialDeptment j = new JudicialDeptment();
		 if (jname == null) {
				jname = "";
			}
		 j.setName(jname);
	     Map map = new HashMap<String,Object>();
	     map.put("pageSize",pageSize);
	     map.put("pageNum", pageNum);
	     map.put("job",job);
	     map.put("correctedPerson",c);
	     map.put("judicialDeptment",j);
	     logger.debug(map);
	     Page p = el.getAll(map);
	     logger.debug(p);
	     if (p != null) {
				List<Object> e = new ArrayList();
				e.add(p);
				rd.setCode(0);
				rd.setMessage("查询成功！");
				rd.setData(e);
			}
		return rd;
	}
	
}


